﻿<UserControl x:Class="ICSharpCode.SharpDevelop.Widgets.ColorPicker"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:widgets="clr-namespace:ICSharpCode.SharpDevelop.Widgets"
             x:Name="this"
             Padding="5"
             Width="373">
	
	<UserControl.Resources>
		
		<DrawingBrush x:Key="ChessBrush"
		              TileMode="Tile"
		              ViewportUnits="Absolute"
		              Viewport="0 0 9 9">
			<DrawingBrush.Drawing>
				<DrawingGroup>
					<GeometryDrawing Brush="White">
						<GeometryDrawing.Geometry>
							<RectangleGeometry Rect="0 0 2 2" />
						</GeometryDrawing.Geometry>
					</GeometryDrawing>
					<GeometryDrawing Brush="Gray">
						<GeometryDrawing.Geometry>
							<GeometryGroup>
								<RectangleGeometry Rect="0 0 1 1" />
								<RectangleGeometry Rect="1 1 1 1" />
							</GeometryGroup>
						</GeometryDrawing.Geometry>
					</GeometryDrawing>
				</DrawingGroup>
			</DrawingBrush.Drawing>
		</DrawingBrush>
	
	</UserControl.Resources>
	
	<DockPanel>
		
		<StackPanel VerticalAlignment="Top"
		            DockPanel.Dock="Right"
		            Margin="10 0 0 0">
			
			<Border Background="{StaticResource ChessBrush}"
			        HorizontalAlignment="Right"
			        BorderBrush="Black"
			        BorderThickness="1"
			        Height="50"
			        Width="70">
				<Rectangle>
					<Rectangle.Fill>
						<SolidColorBrush Color="{Binding Color, ElementName=this}" />
					</Rectangle.Fill>
				</Rectangle>
			</Border>
			
			<DockPanel Margin="0 3 0 0">
				<widgets:HexTextBox Text="{Binding Hex, ElementName=this, UpdateSourceTrigger=PropertyChanged}"
					Width="70"
					Margin="5 0 0 0"
					DockPanel.Dock="Right" />
				<TextBlock Text="#"
				           VerticalAlignment="Center"
				           HorizontalAlignment="Right" />
			</DockPanel>
			
			<DockPanel Margin="0 3 0 0">
				<widgets:NumericUpDown Value="{Binding H, ElementName=this}"
					Maximum="360"
					Width="70"
					Margin="5 0 0 0"
					DockPanel.Dock="Right" />
				<TextBlock Text="H"
				           VerticalAlignment="Center"
				           HorizontalAlignment="Right" />
			</DockPanel>
			
			<DockPanel Margin="0 3 0 0">
				<widgets:NumericUpDown Value="{Binding S, ElementName=this}"
					Width="70"
					Margin="5 0 0 0"
					DockPanel.Dock="Right" />
				<TextBlock Text="S"
				           VerticalAlignment="Center"
				           HorizontalAlignment="Right" />
			</DockPanel>
			
			<DockPanel Margin="0 3 0 0">
				<widgets:NumericUpDown Value="{Binding V, ElementName=this}"
					Width="70"
					Margin="5 0 0 0"
					DockPanel.Dock="Right" />
				<TextBlock Text="V"
				           VerticalAlignment="Center"
				           HorizontalAlignment="Right" />
			</DockPanel>
			
			<DockPanel Margin="0 3 0 0">
				<widgets:NumericUpDown Value="{Binding R, ElementName=this}"
					Maximum="255"
					Width="70"
					Margin="5 0 0 0"
					DockPanel.Dock="Right" />
				<TextBlock Text="R"
				           VerticalAlignment="Center"
				           HorizontalAlignment="Right" />
			</DockPanel>
			
			<DockPanel Margin="0 3 0 0">
				<widgets:NumericUpDown Value="{Binding G, ElementName=this}"
					Maximum="255"
					Width="70"
					Margin="5 0 0 0"
					DockPanel.Dock="Right" />
				<TextBlock Text="G"
				           VerticalAlignment="Center"
				           HorizontalAlignment="Right" />
			</DockPanel>
			
			<DockPanel Margin="0 3 0 0">
				<widgets:NumericUpDown Value="{Binding B, ElementName=this}"
					Maximum="255"
					Width="70"
					Margin="5 0 0 0"
					DockPanel.Dock="Right" />
				<TextBlock Text="B"
				           VerticalAlignment="Center"
				           HorizontalAlignment="Right" />
			</DockPanel>
			
			<DockPanel Margin="0 3 0 0">
				<widgets:NumericUpDown Value="{Binding A, ElementName=this}"
					Maximum="255"
					Width="70"
					Margin="5 0 0 0"
					DockPanel.Dock="Right" />
				<TextBlock Text="A"
				           VerticalAlignment="Center"
				           HorizontalAlignment="Right" />
			</DockPanel>
		
		</StackPanel>
		
		<Border Margin="10 0 0 0"
		        DockPanel.Dock="Right">
			<widgets:Picker Orientation="Vertical"
				Value="{Binding H, ElementName=this}"
				Minimum="360"
				Maximum="0"
				Marker="{Binding ElementName=arrows}"
				Width="20">
				<Border Margin="0 -1">
					<Border.Background>
						<LinearGradientBrush EndPoint="0 1">
							<GradientStop Offset="0"
							              Color="#F00" />
							<GradientStop Offset="0.16"
							              Color="#F0F" />
							<GradientStop Offset="0.33"
							              Color="#00F" />
							<GradientStop Offset="0.5"
							              Color="#0FF" />
							<GradientStop Offset="0.76"
							              Color="#0F0" />
							<GradientStop Offset="0.85"
							              Color="#FF0" />
							<GradientStop Offset="1"
							              Color="#F00" />
						</LinearGradientBrush>
					</Border.Background>
				</Border>
				<Grid x:Name="arrows"
				      IsHitTestVisible="False"
				      VerticalAlignment="Top"
				      Margin="-5">
					<Path HorizontalAlignment="Left"
					      Data="M 0 0 L 5 5 L 0 10 Z"
					      Fill="Black" />
					<Path HorizontalAlignment="Right"
					      Data="M 0 0 L -5 5 L 0 10 Z"
					      Fill="Black" />
				</Grid>
			</widgets:Picker>
		</Border>
		
		<Border BorderBrush="Black"
		        BorderThickness="1">
			<widgets:Picker Value="{Binding S, ElementName=this}"
				Marker="{Binding ElementName=point}"
				ClipToBounds="True">
				<widgets:Picker Orientation="Vertical"
					Value="{Binding V, ElementName=this}"
					Minimum="100"
					Maximum="0"
					Marker="{Binding ElementName=point}">
					<Rectangle>
						<Rectangle.Fill>
							<LinearGradientBrush EndPoint="1 0">
								<GradientStop Offset="0"
								              Color="White" />
								<GradientStop Offset="1"
								              Color="{Binding HueColor, ElementName=this}" />
							</LinearGradientBrush>
						</Rectangle.Fill>
					</Rectangle>
					<Rectangle>
						<Rectangle.Fill>
							<LinearGradientBrush EndPoint="0 1">
								<GradientStop Offset="0"
								              Color="#0000" />
								<GradientStop Offset="1"
								              Color="#F000" />
							</LinearGradientBrush>
						</Rectangle.Fill>
					</Rectangle>
					<Grid x:Name="point"
					      VerticalAlignment="Top"
					      HorizontalAlignment="Left"
					      Width="12"
					      Height="12"
					      Margin="-6 -6 0 0">
						<Ellipse Stroke="Black"
						         IsHitTestVisible="False" />
						<Ellipse Stroke="White"
						         Margin="1"
						         IsHitTestVisible="False" />
					</Grid>
				</widgets:Picker>
			</widgets:Picker>
		</Border>
	
	</DockPanel>

</UserControl>
